package com.lagou;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;

public class SpringApplication {

        public static void run(Class clzz,String[] args)  {

                ApplicationContext  applicationContext = new ApplicationContext(clzz);
                 String protocol = "org.apache.coyote.http11.Http11NioProtocol";
                //1.构建tomcat对象(遵循JAVAEE规范)
                Tomcat t=new Tomcat();
                //2.构建Connector对象(连接器),负责协议配置,端口配置等
                Connector conn=new Connector(protocol);
                conn.setPort(8089);
                t.getService().addConnector(conn);
                //3.启动tomcat

                try {
                        t.start();
                        System.out.println("tomcat8080");
                } catch (LifecycleException e) {
                        e.printStackTrace();
                }

                //4.阻塞当前线程
                t.getServer().await();


        }
}
